/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
var threeSumClosest = function (nums, target) {
  let arr= [],sum=0,min = Number.MAX_SAFE_INTEGER
  function bc(index){
    if(arr.length===3){
      if(target-sum<min){
        min = sum
      }
     
      return
    }

    for(let i=index;i<nums.length;i++){
      sum+=nums[i]
      arr.push(nums[i])
      bc(i+1)
      arr.pop()
      sum-=nums[i]
    }
  }
  bc(0)

  return min
};

threeSumClosest([1,1,1,0],-100)